package com.equipment;

import java.util.NoSuchElementException;

import com.util.EncodingUtil;

public class ReadSysResponse {

	/**
	 * D1相应
	 *
	 * @param args
	 */
	// 帧开始标记
	private String STX = "55AA";
	// 串口帧序列号
	private String RSCTL = "00";
	// 长度
	private String Length = "";
	// 命令頭
	private String Heand = "DF";
	// 拓展子码
	private String CMD = "D1";
	// 异或效验值
	private String BCC = "";
	// 系统信息
	private String SysInfo = "";
	// 返回00正确 非0错误
	private String Status = "";



	public void analysis(String context)
			throws NoSuchElementException {
		if (!context.substring(12, 14).equals("D1")) {
			throw new NoSuchElementException("读系统信息命令字错误");
		}
		// 判断是否成功
		if (!context.substring(14, 16).equals("00")) {
			throw new NoSuchElementException("读系统失败："+EncodingUtil.getErrorResult(EncodingUtil.hexToDec(context.substring(14, 16))));
		}
		Status = context.substring(14, 16);
		SysInfo = context.substring(16, context.length()-2);
	}



	public String getSTX() {
		return STX;
	}



	public void setSTX(String sTX) {
		STX = sTX;
	}



	public String getRSCTL() {
		return RSCTL;
	}



	public void setRSCTL(String rSCTL) {
		RSCTL = rSCTL;
	}



	public String getLength() {
		return Length;
	}



	public void setLength(String length) {
		Length = length;
	}



	public String getHeand() {
		return Heand;
	}



	public void setHeand(String heand) {
		Heand = heand;
	}



	public String getCMD() {
		return CMD;
	}



	public void setCMD(String cMD) {
		CMD = cMD;
	}



	public String getBCC() {
		return BCC;
	}



	public void setBCC(String bCC) {
		BCC = bCC;
	}



	public String getSysInfo() {
		return SysInfo;
	}



	public void setSysInfo(String sysInfo) {
		SysInfo = sysInfo;
	}



	public String getStatus() {
		return Status;
	}



	public void setStatus(String status) {
		Status = status;
	}

}
